#include "ViewpointFeatureHistogramModel.h"

#include "core/AppDirectory.h"

namespace {
const QString UserFilename = "pcl.viewpoint_feature_histogram_model.json";
}

ViewpointFeatureHistogramModel::ViewpointFeatureHistogramModel()
    : BasePclModel()
{
    setPclHelpPage("https://pcl.readthedocs.io/projects/tutorials/en/master/vfh_estimation.html");
}

ViewpointFeatureHistogramModel& ViewpointFeatureHistogramModel::get()
{
    static ViewpointFeatureHistogramModel instance;
    if (instance.filename().isEmpty()) {
        instance.setFilename(AppDirectory::get().getAppDocFile(UserFilename));
        instance.load();
    }
    return instance;
}

void ViewpointFeatureHistogramModel::fromJson(const QJsonObject& json, QStringList& errorList)
{

    BasePclModel::fromJson(json, errorList);

    pcdFile_ = json["pcdFile"].toString(pcdFile_);
}

QJsonObject ViewpointFeatureHistogramModel::toJson() const
{
    QJsonObject json = BasePclModel::toJson();

    json.insert("pcdFile", QJsonValue(pcdFile_));

    return json;
}
